package com.woniu.demo.controller;

import com.woniu.demo.Vo.ResultVo;
import com.woniu.demo.domain.Stu;
import com.woniu.demo.enums.ResultEnum;
import com.woniu.demo.utils.ResultVoUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * created by woniu201
 * created in 2018/7/8
 */
@RestController
public class controller {

    @RequestMapping(value = "/test1", method = RequestMethod.POST)
    public ResultVo create(@Valid Stu stu, BindingResult bindingResult) {

        if (bindingResult.hasErrors()){
            return ResultVoUtil.fail(ResultEnum.AUTH_FAIL.getCode(), ResultEnum.AUTH_FAIL.getMsg());
        }

        return ResultVoUtil.succ(null);
    }
}
